<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of filtergrid</title>
  <meta name="keywords" content="filtergrid">
  <meta name="description" content="FILTERGRID removes spur rows and columns existing after the grid arrangement process.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- # RADOCCToolbox --><!-- menu.html CornerFinder -->
<h1>filtergrid
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>FILTERGRID removes spur rows and columns existing after the grid arrangement process.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function gridout=filtergrid(grid) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> FILTERGRID removes spur rows and columns existing after the grid arrangement process.
 
 FITLERGRID processes the input grid and iteratively removes rows and
 columns until a rectangular grid is obtained.
 
 INPUTS:
     grid: MxNx2 matrix output by GETGRID
 
 OUTPUTS:
     gridout: VxWx2 matrix containing the filtered grid</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="findcorners.html" class="code" title="function imgcout=findcorners(img,debug)">findcorners</a>	FINDCORNERS is the main function called by the calibration GUI.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function gridout=filtergrid(grid)</a>
0002 <span class="comment">% FILTERGRID removes spur rows and columns existing after the grid arrangement process.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% FITLERGRID processes the input grid and iteratively removes rows and</span>
0005 <span class="comment">% columns until a rectangular grid is obtained.</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% INPUTS:</span>
0008 <span class="comment">%     grid: MxNx2 matrix output by GETGRID</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% OUTPUTS:</span>
0011 <span class="comment">%     gridout: VxWx2 matrix containing the filtered grid</span>
0012 
0013 gridout=grid;
0014 <span class="keyword">while</span> 1
0015     row1count=0;
0016     row2count=0;
0017     col1count=0;
0018     col2count=0;
0019     
0020     rowthresh=size(gridout,1)/2;
0021     colthresh=size(gridout,2)/2;
0022     
0023     <span class="keyword">for</span> y=1:size(gridout,2)
0024         <span class="keyword">if</span> gridout(1,y)
0025             row1count=row1count+1;
0026         <span class="keyword">end</span>
0027         <span class="keyword">if</span> gridout(<span class="keyword">end</span>,y)
0028             row2count=row2count+1;
0029         <span class="keyword">end</span>
0030     <span class="keyword">end</span>
0031     <span class="keyword">for</span> x=1:size(gridout,1)
0032         <span class="keyword">if</span> gridout(x,1)
0033             col1count=col1count+1;
0034         <span class="keyword">end</span>
0035         <span class="keyword">if</span> gridout(x,end)
0036             col2count=col2count+1;
0037         <span class="keyword">end</span>
0038     <span class="keyword">end</span>
0039     
0040     row1count=row1count-rowthresh;
0041     row2count=row2count-rowthresh;
0042     col1count=col1count-colthresh;
0043     col2count=col2count-colthresh;
0044     
0045     <span class="comment">% remove row or column with the least number of points</span>
0046     [mincount,indx]=min([row1count,row2count,col1count,col2count]);
0047     <span class="keyword">if</span> mincount&lt;0
0048         <span class="keyword">switch</span> indx
0049             <span class="keyword">case</span> 1
0050                 gridout(1,:,:)=[];
0051             <span class="keyword">case</span> 2
0052                 gridout(<span class="keyword">end</span>,:,:)=[];
0053             <span class="keyword">case</span> 3                
0054                 gridout(:,1,:)=[];
0055             <span class="keyword">case</span> 4
0056                 gridout(:,<span class="keyword">end</span>,:)=[];
0057         <span class="keyword">end</span>
0058     <span class="keyword">else</span>
0059         <span class="keyword">break</span>;
0060     <span class="keyword">end</span>
0061 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Sun 04-Apr-2010 17:13:59 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>